//
//  XJHUserDefaultUtils.swift
//  PublicPod
//
//  Created by 许俊华 on 2021/9/6.
//

import UIKit

open class XJHUserDefaultUtils: NSObject {
    
    /**
     保存到userdefault
     */
    open class func setValueForKey(value:Any, key:String) -> Void {
        if XJHUtils.isEmpty(value: key as AnyObject) {
            return
        }
        UserDefaults.standard.setValue(value, forKey: key)
        UserDefaults.standard.synchronize()
    }
    
    /**
     根据key从userdefault中移除
     */
    open class func removeValueByKey(key:String) -> Void {
        if XJHUtils.isEmpty(value: key as AnyObject) {
            return
        }
        UserDefaults.standard.removeObject(forKey: key)
        UserDefaults.standard.synchronize()
    }
    
    /**
     根据key从userdefault中获取value
     */
    open class func getValueByKey(key:String) -> AnyObject {
        return UserDefaults.standard.object(forKey: key) as AnyObject
    }
}
